<?php

// Connects to the XE service (i.e. database) on the "localhost" machine
$conn = oci_connect('POST3', 'POST3', '192.168.2.158:1521/POST3');
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

function create_table($conn)
{
  $stmt = oci_parse($conn, "create table post3.hallo (test varchar2(64))");
  oci_execute($stmt);
  echo $conn . " created table\n\n";
}

//create_table($conn);

function drop_table($conn)
{
  $stmt = oci_parse($conn, "drop table post3.hallo");
  oci_execute($stmt);
  echo $conn . " dropped table\n\n";
}


//drop_table($conn);

function insert_data($conn)
{
  $stmt = oci_parse($conn, "insert into post3.hallo
            values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
  oci_execute($stmt, OCI_DEFAULT);
  echo $conn . " inserted hallo\n\n";
}

insert_data($conn);


function delete_data($conn)
{
  $stmt = oci_parse($conn, "delete from post3.hallo");
  oci_execute($stmt, OCI_DEFAULT);
  echo $conn . " deleted hallo\n\n";
}

//delete_data($conn);

function commit($conn)
{
  oci_commit($conn);
  echo $conn . " committed\n\n";
}


function select_data($conn)
{
  $stmt = oci_parse($conn, "select * from post3.hallo");
  oci_execute($stmt, OCI_DEFAULT);
  echo $conn."----selecting<br/><br/>";
  while (oci_fetch($stmt)) {
    echo $conn . " [" . oci_result($stmt, "TEST") . "]<br/><br/>";
  }
  echo $conn . "----done<br/><br/>";
}
//commit($conn);


select_data($conn);

//var_dump($conn); 

?>